using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Tools
{
    public static class Validator
    {
        static public bool Validate()
        {
            FileInfo fi = new FileInfo("key.rgs");
            if(fi.Exists == false)
                return false;

            HardwareInfo info = new HardwareInfo();
            DataStructures.HWInfo hwInfo = new DataStructures.HWInfo();
            info.getHardWareSignature(ref hwInfo);
            string k1 = BuildKey(hwInfo);
            using (StreamReader sr = new StreamReader("key.rgs")) 
            {
                string k2 = sr.ReadLine();

                if(k1 == k2)
                    return true;
            }
            return false;
        }

        static public string BuildKey(DataStructures.HWInfo hwInfo)
        {
            return "1@"+                        //2
                hwInfo.cpuID.Substring(2,4)     //4
                + "78"                          //2
                + hwInfo.macID.Substring(0,2)   //2
                + hwInfo.cpuID.Substring(1,4)   //4
                + hwInfo.macID.Substring(2,2)   //2
                + hwInfo.cpuID.Substring(0,3);  //3
                                                //19
        }
    }
}
